package com.bs.modules.use.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bs.common.utils.PageUtils;
import com.bs.common.utils.Query;

import com.bs.modules.use.dao.AppUserDao;
import com.bs.modules.use.entity.AppUserEntity;
import com.bs.modules.use.service.AppUserService;


@Service("appUserService")
public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> implements AppUserService {

  @Autowired
  private AppUserDao appUserDao;

  @Override
  public PageUtils queryPage(Map<String, Object> params) {
    IPage<AppUserEntity> page = this.page(
      new Query<AppUserEntity>().getPage(params),
      new QueryWrapper<AppUserEntity>()
    );

    return new PageUtils(page);
  }

  @Override
  public AppUserEntity findAppUserByAppId(Object appId) {
    return appUserDao.findAppUserByAppId(String.valueOf(appId));
  }

  @Override
  public void bingUserId(Object openid, Object userId) {
    appUserDao.bingUserId(String.valueOf(openid), Long.parseLong((String) userId));
  }

  @Override
  public AppUserEntity findUserId(Long userId) {
    return appUserDao.findUserId(userId);
  }

}
